<template>
	<view class="page-content">
		<view class="n_title">{{title}}</view>
		<view class="content-content">
			<view  v-for="(c,cdx) in classify" :key="'c'+cdx">
				<view class="uni-row1 d-pannel device-classify">
					<view class="uni-row">
						<view class="uni-row1-icon"></view>
						<view class="uni-row1-title">{{c.name}}</view>
					</view>
					<view class="uni-row1-mote" @click="more(c)">查看更多</view>
				</view>
				<view class="">
					<view v-for="(d,dix) in c.devices" :key="'d'+dix" class="device-item">
						<view class="uni-row d-pannel" @click="detail(d)">
							<view class="device1 ellipsis_p">
								<view>{{d.name}}</view>
								<view>{{d.regionPname}}</view>
								<view>{{d.regionName}}</view>
							</view>
							<view class="device2 ellipsis_p">
								<view>{{d.no}}</view>
								<view>{{d.supplierBrandName}}</view>
								<view>{{d.supplierBrandModelName}}</view>
							</view>
							<view class="device3">
								<view v-if="d.status=='1'" class="btn1">入库</view>
								<view v-if="d.status=='2'" class="btn2">出库</view>
								<view v-if="d.status=='3'" class="btn3">使用</view>
								<view v-if="d.status=='4'" class="btn4">维护</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '设备',
				classify:[
					{
						name:null,
						icon:null,
						devices:[
							{
								id:null,
								name:null,
								no:null,
								regionPname:null,
								regionName:null,
								supplierBrandName:null,
								supplierBrandModelName:null,
								runSatus:null,
								status:null
							}
						]
					}
				],
			}
		},
		onShow(){
			this.getData()
		},

		onLoad() {
			
		},
		methods: {
			getData(){
				let url='/api/classify/list'
				this.common.get(url,null,(res)=>{
					if(res.code!=1){
						this.common.showError(res.msg)
						return
					}
					this.classify = res.data
				})
			},
			more(d){
				uni.navigateTo({
					url: '/pages/device/list?classify='+d.id+'&classifyName='+d.name
				});
			},
			detail(d){
				uni.navigateTo({
					url: '/pages/device/detail?id='+d.id+'&name='+d.name
				});
			},

		}
	}
</script>

<style>
	.content-content{
		padding-bottom: 10px;
	}
	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
	.device-classify{
		margin-top: 10px;
	}
	.device-item{
		margin-top: 10px;
	}
	.device1{
		width: 130px;
	}
	.device2{
		width: calc((100% - 200px));
	}
	.device3{
		width: 50px;
	}
</style>
